﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="User_Dict.aspx.cs" Inherits="KPI_SYSTEM.DictPage.User_Dict" %>

<!DOCTYPE html>
<html>
<head runat="server">
    <title></title>
    <style>
        
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <f:PageManager ID="PageManager1" runat="server" />
        <f:Form ID="Form2" IsFluid="true" CssClass="blockpanel" BodyPadding="5 5 0 5" LabelAlign="Left" ShowHeader="false"
            Title="查询" runat="server">
            <Rows>
                <f:FormRow ColumnWidths="15% 15% 15% 15% 15% 15%">
                    <Items>
                        <f:TextBox runat="server" ID="tbxNameSerach" Label="姓名"></f:TextBox>
                        <f:TextBox runat="server" ID="tbxCodeSerach" Label="员工编号"></f:TextBox>
                        <f:DropDownList ID="ddlSearchDept" Width="150px" Label="所属部门" AutoSelectFirstItem="true" runat="server">
                        </f:DropDownList>
                        <f:Button ID="btnSearch" Text="搜索" Icon="Magnifier" runat="server" OnClick="btnSearch_Click"></f:Button>
                        <f:Button ID="btnExport" Text="导出" runat="server" EnableAjax="false" DisableControlBeforePostBack="false" OnClick="btnExport_Click"></f:Button>
                    </Items>
                    <Items>
                    </Items>
                </f:FormRow>
            </Rows>
        </f:Form>
        <f:Grid ID="Grid1" IsFluid="true" CssClass="blockpanel" ShowBorder="true" ShowHeader="true" EnableCollapse="false"
            runat="server" DataKeyNames="REC_ID" AllowCellEditing="false" PageSize="15" AllowPaging="true"
            DataIDField="REC_ID" Title="人员信息维护" OnRowCommand="Grid1_RowCommand" OnPreRowDataBound="Grid1_PreRowDataBound">
            <Toolbars>
                <f:Toolbar ID="Toolbar2" Position="Top" runat="server">
                    <Items>
                        <f:Button ID="btnNew" Text="新增" Icon="Add" EnablePostBack="false" runat="server">
                            <Listeners>
                                <f:Listener Event="click" Handler="onNewButtonClick" />
                            </Listeners>
                        </f:Button>
                        <f:Button ID="btnSyncPerson" Text="单人同步" Icon="ArrowDown" DisableControlBeforePostBack="false"  EnableAjax="false"  runat="server"  OnClick="btnSyncPerson_Click">
                        </f:Button>
                        <f:Button ID="btnSyncUser" Text="同步钉钉" Icon="ArrowDown" DisableControlBeforePostBack="false"  EnableAjax="false"  runat="server" OnClientClick="showLoading()" OnClick="btnSyncUser_Click">
                        </f:Button>
                    </Items>
                </f:Toolbar>
            </Toolbars>
            <Columns>
                <f:RenderField Width="100px" ColumnID="USER_NAME" DataField="USER_NAME"
                    HeaderText="姓名">
                </f:RenderField>
                <f:RenderField Width="120px" ColumnID="USER_CODE" DataField="USER_CODE"
                    HeaderText="员工工号">
                </f:RenderField>
                <f:RenderField Width="200px" ColumnID="DING_USER_ID" DataField="DING_USER_ID"
                    HeaderText="钉钉编号">
                </f:RenderField>
                <%--                <f:RenderField Width="100px" ColumnID="USER_SEX_NAME" DataField="USER_SEX_NAME"
                    HeaderText="性别">
                </f:RenderField>--%>
<%--                <f:RenderField Width="100px" ColumnID="USER_AGE" DataField="USER_AGE"
                    HeaderText="年龄">
                </f:RenderField>--%>
                <f:RenderField Width="120px" ColumnID="USER_PHONE" DataField="USER_PHONE"
                    HeaderText="电话">
                </f:RenderField>
                <f:RenderField Width="100px" ColumnID="USER_ROLE_NAME" DataField="USER_ROLE_NAME"
                    HeaderText="用户角色">
                </f:RenderField>
                <f:RenderField Width="200px" ColumnID="USER_DEPT_NAME" DataField="USER_DEPT_NAME"
                    HeaderText="所属科室">
                </f:RenderField>
                <f:RenderField Width="80px" ColumnID="USER_STATUS_NAME" DataField="USER_STATUS_NAME"
                    HeaderText="是否启用">
                </f:RenderField>
<%--                <f:RenderField Width="150px" ColumnID="USER_TYPE_NAME" DataField="USER_TYPE_NAME"
                    HeaderText="账号类别">
                </f:RenderField>--%>
                <f:RenderField Width="150px" ColumnID="DEPT_REMARK" DataField="DEPT_REMARK"
                    HeaderText="备注">
                </f:RenderField>
                <%--                <f:RenderField  Hidden="true" ColumnID="USER_SEX" DataField="USER_SEX"
                    HeaderText="用户性别ID">
                </f:RenderField>--%>
<%--                <f:RenderField Hidden="true" ColumnID="USER_TYPE" DataField="USER_TYPE"
                    HeaderText="用户类别ID">
                </f:RenderField>--%>
                <f:RenderField Hidden="true" ColumnID="USER_ROLE" DataField="USER_ROLE"
                    HeaderText="用户角色ID">
                </f:RenderField>
                <f:RenderField Hidden="true" ColumnID="USER_DEPT" DataField="USER_DEPT"
                    HeaderText="用户部门ID">
                </f:RenderField>
                <f:RenderField Hidden="true" ColumnID="USER_STATUS" DataField="USER_STATUS"
                    HeaderText="用户状态ID">
                </f:RenderField>
                <f:LinkButtonField ColumnID="Edit" Width="50px" EnablePostBack="false"
                    Icon="Pencil" />
                <f:LinkButtonField Width="50px" ConfirmText="删除选中行？" ConfirmTarget="Top"
                    CommandName="Delete" Icon="Delete" />
            </Columns>
        </f:Grid>

        <f:Window ID="Window1" Title="编辑信息" Hidden="true" EnableIFrame="false"
            EnableMaximize="true" Target="Self" EnableResize="true" runat="server"
            IsModal="true" Width="650px">
            <Items>
                <f:SimpleForm ID="SimpleForm1" runat="server" ShowBorder="false" ShowHeader="false" BodyPadding="10px">
                    <Items>
                        <f:Panel ID="Panel1" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                                <f:HiddenField ID="hfFormID" runat="server"></f:HiddenField>
                                <f:TextBox ID="tbxFormUSER_NAME" Width="310px" Label="姓名" runat="server" Required="true" ShowRedStar="true"></f:TextBox>
                                <f:TextBox ID="tbxFormUSER_PHONE" Width="310px" MarginLeft="20px" Label="电话" runat="server"></f:TextBox>
                                <%--<f:NumberBox  ID="tbxFormUSER_AGE" Width="310px" NoDecimal="true" ShowTrigger="false" Label="年龄"  runat="server"></f:NumberBox>--%>
                                <%--    <f:DropDownList ID="ddlFormUSER_SEX" Width="310px" MarginLeft="20px" Label="性别"  AutoSelectFirstItem="true" runat="server">
                                    <f:ListItem Text="男" Value="1" />
                                    <f:ListItem Text="女" Value="2" />
                                </f:DropDownList>--%>
                            </Items>
                        </f:Panel>
                    </Items>
                    <Items>
                        <f:Panel ID="Panel2" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                                <f:TextBox ID="tbxFormUSER_CODE" Width="310px" Label="员工工号" runat="server" Required="true" ShowRedStar="true"></f:TextBox>
                                <f:TextBox ID="tbxFormDING_USER_ID" Width="310px" MarginLeft="20px" Label="钉钉编号" runat="server"></f:TextBox>
                            </Items>
                        </f:Panel>
                    </Items>
                    <Items>
                        <f:Panel ID="Panel6" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                                <f:DropDownList ID="ddlFormUSER_ROLE" Width="310px" Label="用户角色" AutoSelectFirstItem="true" runat="server">
                                </f:DropDownList>
                                <f:DropDownList ID="ddlFormUSER_DEPT" Width="310px" MarginLeft="20px" Label="所属部门" EnableEdit="true" AutoSelectFirstItem="true" runat="server">
                                </f:DropDownList>
                            </Items>
                        </f:Panel>
                    </Items>
                    <Items>
                        <f:Panel ID="Panel4" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                                <%--                                <f:DropDownList ID="ddlFormUSER_TYPE" Width="310px" Label="用户类别"  AutoSelectFirstItem="true" runat="server">
                                   <f:ListItem Text="系统操作员" Value="1" />
                                    <f:ListItem Text="非系统操作员" Value="0" />
                             </f:DropDownList>--%>
                                <f:DropDownList ID="ddlFormUSER_STATUS" Width="310px" Label="是否启用" AutoSelectFirstItem="true" runat="server">
                                    <f:ListItem Text="是" Value="1" />
                                    <f:ListItem Text="否" Value="0" />
                                </f:DropDownList>
                                <f:TextBox ID="tbxFormUSER_REMARK" Width="310px" MarginLeft="20px" Label="备注" runat="server"></f:TextBox>
                            </Items>
                        </f:Panel>
                    </Items>
                    <Toolbars>
                        <f:Toolbar ID="Toolbar1" Position="Bottom" ToolbarAlign="Right" runat="server">
                            <Items>
                                <f:Button ID="btnSave"
                                    Icon="SystemSave" runat="server" Text="保存数据" ValidateForms="SimpleForm1" OnClick="btnSave_Click">
                                </f:Button>
                            </Items>
                        </f:Toolbar>
                    </Toolbars>
                </f:SimpleForm>
            </Items>
        </f:Window>

        <f:Window ID="Window2" Title="编辑信息" Hidden="true" EnableIFrame="false" EnableClose="false" ShowHeader="false"
            EnableMaximize="false" Target="Self" EnableResize="true" runat="server"
            IsModal="true" Width="650px">
            <Items>
                <f:SimpleForm ID="SimpleForm2" runat="server" ShowBorder="false" ShowHeader="false" BodyPadding="10px">
                    <Items>
                        <f:Panel ID="Panel3" ShowHeader="false" CssClass="" ShowBorder="false" Layout="Column" runat="server">
                            <Items>
                               <f:Label ID="labldingding" runat="server" Text="正在同步，请稍后......"></f:Label>
                            </Items>
                        </f:Panel>
                    </Items>
                </f:SimpleForm>
            </Items>
        </f:Window>
        <br />
        <br />
        <br />
    </form>
    <script src="../res/js/ApprovalButton.js"></script>
    <script>
        var windowClientID = '<%= Window1.ClientID %>';
        var gridClientID = '<%= Grid1.ClientID %>';
        var btnSaveClientID = '<%= btnSave.ClientID %>';
        var formClientID = '<%= SimpleForm1.ClientID %>';
        var hfFormIDClientID = '<%= hfFormID.ClientID %>';
        var tbxFormUSER_NAMEClientID = '<%= tbxFormUSER_NAME.ClientID %>';
<%--        var ddlFormUSER_SEXClientID = '<%= ddlFormUSER_SEX.ClientID %>';
        var tbxFormUSER_AGEClientID = '<%= tbxFormUSER_AGE.ClientID %>';--%>
        var tbxFormUSER_PHONEClientID = '<%= tbxFormUSER_PHONE.ClientID %>';
        var tbxFormUSER_CODEClientID = '<%= tbxFormUSER_CODE.ClientID %>';
        var tbxFormDING_USER_IDClientID = '<%= tbxFormDING_USER_ID.ClientID %>';
<%--        var ddlFormUSER_TYPEClientID = '<%= ddlFormUSER_TYPE.ClientID %>';--%>
        var ddlFormUSER_ROLEClientID = '<%= ddlFormUSER_ROLE.ClientID %>';
        var ddlFormUSER_DEPTClientID = '<%= ddlFormUSER_DEPT.ClientID %>';
        var ddlFormUSER_STATUSClientID = '<%= ddlFormUSER_STATUS.ClientID %>';
        var tbxFormUSER_REMARKClientID = '<%= tbxFormUSER_REMARK.ClientID %>';

        function showLoading() {
            var window2ClientID = '<%= Window2.ClientID %>';
              F(window2ClientID).show();
        }
        function onNewButtonClick(event) {
            // 重置表单字段
            F(formClientID).reset();
            F(hfFormIDClientID).setValue(null);
            // 弹出窗体
            F(windowClientID).show();
            F(windowClientID).setTitle('新增数据');
        }
        function onEditButtonClick(event) {
            showEditWindow();
        }
        function showEditWindow(rowId) {
            var grid = F(gridClientID);

            // 如果传入参数为空，则获取当前选中行
            if (!rowId) {
                var selectedRowIds = grid.getSelectedRows();
                if (!selectedRowIds.length) {
                    F.alert('请至少选择一项！');
                    return;
                }

                rowId = selectedRowIds[0];
            }
            F(windowClientID).setTitle('编辑数据');
            // 当前行数据
            var rowValue = grid.getRowValue(rowId);
            // 使用当前行数据填充表单字段
            F(hfFormIDClientID).setValue(rowId);
            F(tbxFormUSER_NAMEClientID).setValue(rowValue['USER_NAME']);
            //F(ddlFormUSER_SEXClientID).setValue(rowValue['USER_SEX']);
            //F(tbxFormUSER_AGEClientID).setValue(rowValue['USER_AGE']);
            F(tbxFormUSER_PHONEClientID).setValue(rowValue['USER_PHONE']);
            F(tbxFormUSER_CODEClientID).setValue(rowValue['USER_CODE']);
            F(tbxFormDING_USER_IDClientID).setValue(rowValue['DING_USER_ID']);
            //F(ddlFormUSER_TYPEClientID).setValue(rowValue['USER_TYPE']);
            F(ddlFormUSER_ROLEClientID).setValue(rowValue['USER_ROLE']);
            F(ddlFormUSER_DEPTClientID).setValue(rowValue['USER_DEPT']);
            F(ddlFormUSER_STATUSClientID).setValue(rowValue['USER_STATUS']);
            F(tbxFormUSER_REMARKClientID).setValue(rowValue['USER_REMARK']);
            // 弹出新增窗体
            F(windowClientID).show();
        }
    </script>
</body>
</html>
